<?php

/**
 * user actions.
 *
 * @package    Wildlive
 * @subpackage user
 * @author     Maximilian Lenkeit <dev@lenki.com>
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class userActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->forward('default', 'module');
  }
  
  public function executeSelfService(sfWebRequest $request)
  {
    $this->change_password_form = new GuardChangeUserPasswordForm();
  }
  
  public function executeSelfServiceChangePassword(sfWebRequest $request)
  {
    $this->change_password_form = new GuardChangeUserPasswordForm();
    $this->change_password_form->bind($request->getParameter( $this->change_password_form->getName()), $request->getFiles( $this->change_password_form->getName()));
    
    if($this->change_password_form->isValid()) {
      $user = $this->getUser();
      $user->setPassword($this->change_password_form->getValue('password'));
      $this->getUser()->setFlash(UserFlash::SUCCESS, 'Dein Passwort wurde erfolgreich geändert.');
      $this->redirect($this->generateUrl('user_self_service'));
    } else {
      $this->form_errors = BaseForm::collectErrors($this->change_password_form);
      $this->setTemplate('selfService');
    }
  }
}
